package ${package}.${moduleName}.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import ${package}.common.code.controller.BaseController;
import ${package}.common.utils.AjaxResult;
import ${package}.framework.entity.page.PageQuery;
import ${package}.framework.entity.page.TableDataInfo;
import ${package}.${moduleName}.entity.bo.${ClassName}Bo;
import ${package}.${moduleName}.entity.vo.${ClassName}Vo;
import ${package}.${moduleName}.service.${ClassName}Service;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
* ${tableComment}
*
* @author ${author} ${email}
* @since ${version} ${date}
*/
@Slf4j
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("${moduleName}/${functionName}")
public class ${ClassName}Controller extends BaseController{
    private final ${ClassName}Service baseService;


    @SaCheckPermission("${moduleName}:${functionName}:list")
    @PostMapping("/list")
    public TableDataInfo<${ClassName}Vo> listPage(@Validated @RequestBody(required = false) ${ClassName}Bo bo, PageQuery pageQuery){
         return baseService.selectListVoPage(bo, pageQuery);
    }

    @SaCheckPermission("${moduleName}:${functionName}:query")
    @GetMapping("/{id}")
    public AjaxResult<${ClassName}Vo> queryById(@PathVariable String id) {
        return success(baseService.selectVoById(id));
    }

    @SaCheckPermission("${moduleName}:${functionName}:edit")
    @PutMapping
    public AjaxResult<Boolean> edit(@Validated @RequestBody(required = false) ${ClassName}Bo bo) {
        return success(baseService.updateById(bo));
    }

    @SaCheckPermission("${moduleName}:${functionName}:insert")
    @PostMapping
    public AjaxResult<Boolean> insert(@Validated @RequestBody(required = false) ${ClassName}Bo bo) {
        return success(baseService.insert(bo));
    }

    @SaCheckPermission("${moduleName}:${functionName}:delete")
    @DeleteMapping("/{id}")
    public AjaxResult<Boolean> delete(@PathVariable String id) {
        return success(baseService.deleteById(id));
    }

}
